'''
Created on 2010/07/06

@author: saburo
'''
from pyrfid.Util.Util import Util
from pyrfid.asn1.Decoder import Decoder

class DataSet(object):
    '''
    classdocs
    '''
    
    __slots__ = ["PRECURSOR", "LENGTH_OF_OBJECT", "OBJECT", "OFFSET", "OBJECT_IDENTIFIER", "LENGTH_OF_OBJECT_IDENTIFIER", "PAD", "IS_ADDED"]

    def __init__(self):
        '''
        Constructor
        '''
        self.PRECURSOR = ""
        self.LENGTH_OF_OBJECT = ""
        self.OBJECT = ""
        self.OFFSET = ""
        self.OBJECT_IDENTIFIER = ""
        self.LENGTH_OF_OBJECT_IDENTIFIER = ""
        self.PAD = ""
        self.IS_ADDED = False
            
    def showDataSet(self):
        print "precursor["+self.PRECURSOR+"]  OFFSET["+self.OFFSET+"] length of Object type["+self.LENGTH_OF_OBJECT_IDENTIFIER +"] Object Identifier["+self.OBJECT_IDENTIFIER+"] length of OBJECT ["+self.LENGTH_OF_OBJECT+"] OBJECT["+self.OBJECT+"] pad ["+self.PAD+"]"
    
    def getLogicalMemory(self):
        logical_memory =  Util.convertBitToHex(self.PRECURSOR) + self.OFFSET + self.LENGTH_OF_OBJECT_IDENTIFIER + self.OBJECT_IDENTIFIER  + self.LENGTH_OF_OBJECT + self.OBJECT + self.PAD
        return logical_memory 
    
    def getCompactionType(self):
        return int(self.PRECURSOR[1:4], 2)
    
    def getLogicalMemoryForRegistratedUIIMemory(self):
        "To Use a defined AFI, which means that DSFID, Precurosr, "
        return self.OBJECT
        
    def isAdded(self):
        self.IS_ADDED = True
        